package main

import (
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"github.com/spf13/viper"
	"os"
)

func main() {
	InitConfig()
	r := SetupRouter()
	port := viper.GetString("server.port")
	if err := r.Run(port); err != nil {
		fmt.Println("startup service failed, err:%v\n", err)
	}
}

func InitConfig() {
	workDir,_ := os.Getwd()
	viper.SetConfigName("application")
	viper.SetConfigType("yml")
	viper.AddConfigPath(workDir+"/config")
	err := viper.ReadInConfig()
	if err!=nil{
		panic(err)
	}
}

